

#ifndef ZGEOMENT_DBSUBEID_H
#define ZGEOMENT_DBSUBEID_H

#include "zacdb.h"
#include "zdbidar.h"
#include "ZRXExports.h"

#pragma pack (push, 8)

class UcDbSubentId
{
public:
    UcDbSubentId();
    UcDbSubentId(UcDb::SubentType type, ZSoft::GsMarker index);
    UcDbSubentId(UcRxClass* pTypeClass, ZSoft::GsMarker index);

    bool               operator ==(const UcDbSubentId& id) const;
    bool               operator !=(const UcDbSubentId& id) const;

    UcDb::SubentType   type () const;
    void               setType(UcDb::SubentType);
    UcRxClass*         typeClass () const;
    void               setTypeClass(UcRxClass* pClass);
    ZSoft::GsMarker    index() const;
    void               setIndex(ZSoft::GsMarker);
    
private:
    UcDb::SubentType mType;
    ZSoft::GsMarker  mIndex;
    UcRxClass*       mpTypeClass;
};

const ZSoft::GsMarker kNullSubentIndex = 0;
__declspec(selectany) extern const UcDbSubentId kNullSubentId(UcDb::kNullSubentType, kNullSubentIndex);

class UcDbFullSubentPath
{
public:
    UcDbFullSubentPath();
    UcDbFullSubentPath(UcDb::SubentType type, ZSoft::GsMarker index);
    UcDbFullSubentPath(UcDbObjectId entId, UcDb::SubentType type, ZSoft::GsMarker index);
    UcDbFullSubentPath(UcDbObjectId entId, UcDbSubentId subId);
    UcDbFullSubentPath(UcDbObjectIdArray objectIds, UcDbSubentId subId);
    UcDbFullSubentPath(const UcDbFullSubentPath&);
    ~UcDbFullSubentPath();

    UcDbFullSubentPath&     operator =  (const UcDbFullSubentPath&);

    bool           operator ==(const UcDbFullSubentPath& id) const;
    bool           operator !=(const UcDbFullSubentPath& id) const;

    void                objectIds(UcDbObjectIdArray& objectIds) const;
    UcDbObjectIdArray&  objectIds();
    const UcDbObjectIdArray&  objectIds() const;
    const UcDbSubentId  subentId () const;
    UcDbSubentId&       subentId ();
	void* userAppData() const;
	void setUserAppData(void* pData);
private:                            
    UcDbObjectIdArray mObjectIds;
    UcDbSubentId      mSubentId;
	void*             mpUserAppData;
};

inline UcDb::SubentType
UcDbSubentId::type () const
{
    return mType;
}

inline void
UcDbSubentId::setType(UcDb::SubentType type)
{
    mType = type;
    if (mType != UcDb::kClassSubentType)
        mpTypeClass = nullptr;
}

inline ZSoft::GsMarker
UcDbSubentId::index() const
{
    return mIndex;
}

inline void
UcDbSubentId::setIndex(ZSoft::GsMarker index)
{
    mIndex = index;
}

inline UcRxClass*
UcDbSubentId::typeClass() const
{
    return mpTypeClass;
}

inline void
UcDbSubentId::setTypeClass(UcRxClass* pTypeClass)
{
    mpTypeClass = pTypeClass;
    if (mpTypeClass != nullptr)
        mType = UcDb::kClassSubentType;
}

inline
UcDbSubentId::UcDbSubentId() 
    : mType(UcDb::kNullSubentType), mIndex(kNullSubentIndex), mpTypeClass(nullptr)
{
}

inline
UcDbSubentId::UcDbSubentId(UcDb::SubentType t, ZSoft::GsMarker i)
    : mType(t), mIndex(i), mpTypeClass(nullptr)
{
}

inline
UcDbSubentId::UcDbSubentId(UcRxClass* pTypeClass, ZSoft::GsMarker i)
    : mType(UcDb::kClassSubentType), mIndex(i), mpTypeClass(pTypeClass)
{
}

inline bool
UcDbSubentId::operator ==(const UcDbSubentId& id) const
{
    return ((mIndex == id.mIndex)
            && (mType == id.mType)
            && (mpTypeClass == id.mpTypeClass));
}

inline bool
UcDbSubentId::operator !=(const UcDbSubentId& id) const
{
    return ((mIndex != id.mIndex)
            || (mType != id.mType)
            || (mpTypeClass != id.mpTypeClass));
}

inline
UcDbFullSubentPath::UcDbFullSubentPath() 
{
}

inline
UcDbFullSubentPath::UcDbFullSubentPath(UcDb::SubentType type,
                                       ZSoft::GsMarker index)
    : mSubentId(type, index)
{
}

inline void
UcDbFullSubentPath::objectIds(UcDbObjectIdArray& objectIds) const
{
    objectIds = mObjectIds;
}

inline UcDbObjectIdArray&
UcDbFullSubentPath::objectIds()
{
    return mObjectIds;
}

inline const UcDbObjectIdArray&
UcDbFullSubentPath::objectIds() const
{
    return mObjectIds;
}

inline const UcDbSubentId
UcDbFullSubentPath::subentId () const
{
    return mSubentId;
}

inline UcDbSubentId&
UcDbFullSubentPath::subentId ()
{
    return mSubentId;
}

inline void*
UcDbFullSubentPath::userAppData() const
{
	return mpUserAppData;
}

inline void
UcDbFullSubentPath::setUserAppData(void* pData)
{
	mpUserAppData = pData;
}


#pragma pack (pop)

#endif

